Import ED Visits dataset

We will use the pared down dataset created earlier.

flu_visits = 
  read_csv("./ed_flu_tidy.csv")
## Parsed with column specification:
## cols(
##   extract_date = col_date(format = ""),
##   date = col_date(format = ""),
##   mod_zcta = col_double(),
##   total_ed_visits = col_double(),
##   ili_pne_visits = col_double(),
##   ili_pne_admissions = col_double(),
##   pct_visits = col_double(),
##   pct_adm = col_double()
## )

Pull in zip code/borough tibble from the web.

url = "https://www.health.ny.gov/statistics/cancer/registry/appendix/neighborhoods.htm"

zip_boro_html = read_html(url)

zip_boro_df = 
  zip_boro_html %>% 
  html_nodes(css = "table") %>% 
  html_table(header = TRUE) %>% 
  colnames()
  as_tibble(rownames = c("boro", "neighborhood", "zip_code"))
  mutate(
    boro = as.character(Borough),
    neighborhood = as.character(Neighborhood),
    zip_code = as.character("Zip Codes")
  ) %>% 
  select(-Neighborhood) %>% 
  janitor::clean_names()

Create a map using plotly.

flu_visits %>% 
  mutate(text_label = str_c(
    "Date: ", date, 
    "\n% ILI Visits: ", pct_visits,
    "\n% ILI Admissions: ", pct_adm)) %>% 
  plot_ly(
    x = ~date, y = ~total_ed_visits, color = ~mod_zcta, text = ~text_label,
    alpha = 0.3, type = "scatter", mode = "markers"
  )
## Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
## Please use `arrange()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.